home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / Text / Docu / Controllers (.txt) < prev    next >
Encoding:
Oberon Document  |  1996-07-08  |  7.4 KB  |  178 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Helvetica
  22. Helvetica
  23. Helvetica
  24. Helvetica
  25. Helvetica
  26. TextControllers
  27. DEFINITION TextControllers;
  28.     IMPORT Models, Views, Containers, TextModels, TextViews;
  29.     CONST
  30.         noAutoScroll = 16; noAutoIndent = 17;
  31.         none = -1;
  32.     TYPE
  33.         LONGCHAR = INTEGER;
  34.         Controller = POINTER TO ControllerDesc;
  35.         ControllerDesc = RECORD (Containers.ControllerDesc)
  36.             view-: TextViews.View;
  37.             text-: TextModels.Model;
  38.             PROCEDURE (c: Controller) InitView (v: Views.View);
  39.             PROCEDURE (c: Controller) CaretPos (): LONGINT;
  40.             PROCEDURE (c: Controller) SetCaret (pos: LONGINT);
  41.             PROCEDURE (c: Controller) GetSelection (VAR beg, end: LONGINT);
  42.             PROCEDURE (c: Controller) SetSelection (beg, end: LONGINT)
  43.         END;
  44.         Directory = POINTER TO DirectoryDesc;
  45.         DirectoryDesc = RECORD (Containers.DirectoryDesc)
  46.             PROCEDURE (d: Directory) NewController (opts: SET): Controller;
  47.             PROCEDURE (d: Directory) New (): Controller
  48.         END;
  49.         ModelMessage = RECORD (Models.Message) END;
  50.         SetCaretMsg = RECORD (ModelMessage)
  51.             pos: LONGINT
  52.         END;
  53.         SetSelectionMsg = RECORD (ModelMessage)
  54.             beg, end: LONGINT
  55.         END;
  56.     VAR dir-, stdDir-: Directory;
  57.     PROCEDURE SetDir (d: Directory);
  58.     PROCEDURE Install;
  59.     PROCEDURE Focus (): Controller;
  60.     PROCEDURE SetCaret (text: TextModels.Model; pos: LONGINT);
  61.     PROCEDURE SetSelection (text: TextModels.Model; beg, end: LONGINT);
  62. END TextControllers.
  63. TextControllers are the standard controllers for text views as defined in TextViews.
  64. CONST noAutoScroll
  65. Possible element of controller option set. If included, automatic scrolling of views is disabled. Autoscrolling is used to show the caret position or to show the position of the modification performed most recently.
  66. CONST noAutoIndent
  67. Possible element of controller option set. If included, automatic indentation after entering a line character is disabled.
  68. CONST none
  69. Possible argument to controller.SetCaret and controller.SetSelection to indicate removal of the caret or the selection, respectively. Likewise, controller.CarPos and controller.GetSelection may return none to indicate the absense of a caret or selection, respectively.
  70. TYPE LONGCHAR = INTEGER
  71. Type of long characters.
  72. TYPE Controller
  73. Interface, Extension
  74. Standard controllers for text views.
  75. view-: TextViews.View
  76. The view to which the controller is connected.
  77. text-: TextModels.Model    view # NIL => text = view.ThisModel()
  78. The text displayed by the controlled view; cached for easy access.
  79. PROCEDURE (c: Controller) InitView (v: Views.View)
  80. Default, Extension
  81. Strengthened preconditions!
  82. v = NIL  #  c.view = NIL    21
  83. c.view = NIL
  84.     v IS TextViews.View    22
  85. v # NIL
  86.     c.view = v
  87.     c.text = c.view.ThisModel()
  88. v = NIL
  89.     c.view = NIL
  90.     c.text = NIL
  91. PROCEDURE (c: Controller) CaretPos (): LONGINT
  92. Interface
  93. Current position of the caret, or none if not set.
  94. result = none  OR  0 <= result <= c.text.Length()
  95. PROCEDURE (c: Controller) SetCaret (pos: LONGINT)
  96. Interface
  97. Set the caret at position pos, or remove the caret if pos = none.
  98. pos = none  OR  0 <= pos    20
  99. pos <= c.text.Length()    21
  100. c.CarPos() = pos
  101. PROCEDURE (c: Controller) GetSelection (VAR beg, end: LONGINT)
  102. Interface
  103. Get the currently selected stretch [beg, end), or beg = end if none exists.
  104. beg = end  OR  0 <= beg <= end <= c.text.Length()
  105. PROCEDURE (c: Controller) SetSelection (beg, end: LONGINT)
  106. Interface
  107. Set the stretch to be selected to [beg, end), or remove the selection if beg = end.
  108. beg = end  OR  0 <= beg < end <= c.text.Length()    20
  109. c.GetSelection(b, e): b = beg, e = end
  110. TYPE Directory
  111. Directory for controllers.
  112. PROCEDURE (d: Directory) NewController (opts: SET): Controller
  113. Interface
  114. Return new controller with options opts.
  115. PROCEDURE (d: Directory) New (): Controller
  116. Default, Extension
  117. Result type is narrowed.
  118. Except for performance, equivalent to:
  119.     RETURN d.NewController({})
  120. TYPE ModelMessage
  121. Interface
  122. Messages to control virtual model extensions, such as marks (e.g. caret or selection).
  123. TYPE SetCaretMsg
  124. Extension
  125. Set the caret in a view displaying text model msg.model.
  126. pos: LONGINT
  127. Set the caret at position pos.
  128. TYPE SetSelectionMsg
  129. Extension
  130. Set the caret in a view displaying text model msg.model.
  131. beg, end: LONGINT
  132. Set the selection to cover the stretch [beg, end).
  133. VAR dir-, stdDir-: Directory    dir # NIL, stdDir # NIL, stable stdDir = d
  134. Directory and standard directory objects for controllers.
  135. PROCEDURE SetDir (d: Directory)
  136. Set the directory object.
  137. d # NIL    20
  138. dir = d
  139. PROCEDURE Install
  140. Install the current controller directory object in TextViews.
  141. Except for performance, equivalent to:
  142.     TextViews.SetCtrlDir(dir)
  143. PROCEDURE Focus (): Controller
  144. Return the text controller that currently has the focus, if any.
  145. Except for performance, equivalent to:
  146.     VAR v: Views.View; c: Controllers.Controller;
  147.     v := Controllers.FocusView();
  148.     IF (v # NIL) & (v IS TextViews.View) THEN
  149.         c := v(TextViews.View).ThisController();
  150.         IF (c # NIL) & (c IS Controller) THEN RETURN c(Controller)
  151.         ELSE RETURN NIL
  152.         END
  153.     ELSE RETURN NIL
  154. PROCEDURE SetCaret (text: TextModels.Model; pos: LONGINT)
  155. In all views displaying text, set the caret to position pos.
  156. text # NIL    20
  157. pos = none  OR  0 <= pos    21
  158. pos <= text.Length()    22
  159. Except for performance, equivalent to:
  160.     VAR cm: SetCaretMsg;
  161.     cm.pos := pos; Models.Broadcast(text, cm)
  162. PROCEDURE SetSelection (text: TextModels.Model; beg, end: LONGINT)
  163. In all views displaying text, set the selection to the stretch [beg, end).
  164. text # NIL    20
  165. beg # end
  166.     0 <= beg    21
  167.     beg < end    22
  168.     end <= text.Length()    23
  169. Except for performance, equivalent to:
  170.     VAR sm: SetSelectionMsg;
  171.     sm.beg := beg; sm.end := end; Models.Broadcast(text, sm)
  172. TextControllers.StdCtrlDesc
  173. TextControllers.ControllerDesc
  174. Containers.ControllerDesc
  175. Controllers.ControllerDesc
  176. Helvetica
  177. Documents.ControllerDesc
  178.